package com.dst.smart.dao.impl.factory;

import java.util.ArrayList;
import java.util.List;

import com.dst.smart.app.MyApplication;
import com.dst.smart.model.GatewayType;

public class GateWayTypeFactory {
	public static List<GatewayType> list = new ArrayList<GatewayType>();

	static {
		if (list.size() == 0) {
			list = MyApplication.getInstance().getWidgetDataBase()
					.getGateWayType();
		}
	}

	public static List<GatewayType> getAll() {
		if (list.size() == 0) {
			list = MyApplication.getInstance().getWidgetDataBase().getGateWayType();
		}
		return list;
	}

	public static List<GatewayType> getLimit(int limit) {

		List<GatewayType> resultList = new ArrayList<GatewayType>();
		if (list.size() == 0) {
			list = MyApplication.getInstance().getWidgetDataBase().getGateWayType();
		}

		if (limit < list.size()) {
			resultList = list.subList(0, limit);
		} else {
			resultList.addAll(list);
		}
		return resultList;
	}


	public static void clearList() {
		list = MyApplication.getInstance().getWidgetDataBase().getGateWayType();
	}
}
